/*******************************************************************************
 * Copyright (c) 2025 Lablicate GmbH.
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Contributors:
 * Philip Wenig - initial API and implementation
 *******************************************************************************/
package org.eclipse.chemclipse.chromatogram.xxd.filter.supplier.scan.calculator;

import static org.junit.Assert.assertEquals;

import org.eclipse.chemclipse.chromatogram.xxd.filter.supplier.scan.core.DensityOperation;
import org.junit.Test;

public class DensityCalculator_3_Test {

	private DensityCalculator densityCalculator = new DensityCalculator();
	private int[] retentionTimes = new int[]{ //
			185526, 185819, 186111, 186404, 186697, 186990, 187282, 187575, 187868, 188161, 188453, 188746, 189039, 189332, 189625, //
			189917, 190210, 190503, 190796, 191088, 191381, 191674, 191967, 192259, 192552, 192845, 193138, 193430, 193723, 194016, //
			194309, 194601, 194894, 195187, 195480, 195773, 196065, 196358, 196651, 196944, 197236, 197529, 197822, 198115, 198407, //
			198700, 198993, 199286, 199578, 199871, 200164, 200457, 200750, 201042, 201335, 201628, 201921, 202213, 202506, 202799, //
			203092, 203384, 203677, 203970, 204263, 204555, 204848, 205141, 205434, 205726, 206019, 206312, 206605, 206898, 207190, //
			207483, 207776, 208069, 208361, 208654, 208947, 209240, 209532, 209825, 210118, 210411, 210703, 210996, 211289, 211582, //
			211874, 212167, 212460, 212753, 213046, 213338, 213631, 213924, 214217, 214509, 214802, 215095, 215388, 215680, 215973, //
			216266, 216559, 216851, 217144, 217437, 217730, 218022, 218315, 218608, 218901, 219194, 219486, 219779, 220072, 220365, //
			220657, 220950, 221243, 221536, 221828, 222121, 222414, 222707, 222999, 223292, 223585, 223878, 224171, 224463, 224756, //
			225049, 225342, 225634, 225927, 226220, 226513, 226805, 227098, 227391, 227684, 227976, 228269, 228562, 228855, 229147, //
			229440, 229733, 230026, 230319, 230611, 230904, 231197, 231490, 231782, 232075, 232368, 232661, 232953, 233246, 233539, //
			233832, 234124, 234417, 234710, 235003, 235295, 235588, 235881, 236174, 236467, 236759, 237052, 237345, 237638, 237930, //
			238223, 238516, 238809, 239101, 239394, 239687, 239980, 240272, 240565, 240858, 241151, 241443, 241736, 242029, 242322, //
			242615, 242907, 243200, 243493, 243786, 244078, 244371, 244664, 244957, 245249, 245542, 245835, 246128, 246420, 246713, //
			247006, 247299, 247592, 247884, 248177, 248470, 248763, 249055, 249348, 249641, 249934, 250226, 250519, 250812, 251105, //
			251397, 251690, 251983, 252276, 252568, 252861, 253154, 253447, 253740, 254032, 254325, 254618, 254911, 255203, 255496, //
			255789, 256082, 256374, 256667, 256960, 257253, 257545, 257838, 258131, 258424, 258716, 259009, 259302, 259595, 259888, //
			260180, 260473, 260766, 261059, 261351, 261644, 261937, 262230, 262522, 262815, 263108, 263401, 263693, 263986, 264279, //
			264572, 264864, 265157, 265450, 265743, 266036, 266328, 266621, 266914, 267207, 267499, 267792, 268085, 268378, 268670, //
			268963, 269256, 269549, 269841, 270134, 270427, 270720, 271013, 271305, 271598, 271891, 272184, 272476, 272769, 273062, //
			273355, 273647, 273940, 274233, 274526, 274818, 275111, 275404, 275697, 275989, 276282, 276575, 276868, 277161, 277453, //
			277746, 278039, 278332, 278624, 278917, 279210, 279503, 279795, 280088, 280381, 280674, 280966, 281259, 281552, 281845, //
			282137, 282430, 282723, 283016, 283309, 283601, 283894, 284187, 284480, 284772, 285065, 285358, 285651, 285943, 286236, //
			286529, 286822, 287114, 287407, 287700, 287993, 288285, 288578, 288871, 289164, 289457, 289749, 290042, 290335, 290628, //
			290920, 291213, 291506, 291799, 292091, 292384, 292677, 292970, 293262, 293555, 293848, 294141, 294434, 294726, 295019, //
			295312, 295605, 295897, 296190, 296483, 296776, 297068, 297361, 297654, 297947, 298239, 298532, 298825, 299118, 299410, //
			299703, 299996, 300289, 300582, 300874, 301167, 301460, 301753, 302045, 302338, 302631, 302924, 303216, 303509, 303802, //
			304095, 304387, 304680, 304973, 305266, 305558, 305851, 306144, 306437, 306730, 307022, 307315, 307608, 307901, 308193, //
			308486, 308779, 309072, 309364, 309657, 309950, 310243, 310535, 310828, 311121, 311414, 311707, 311999, 312292, 312585, //
			312878, 313170, 313463, 313756, 314049, 314341, 314634, 314927, 315220, 315512, 315805, 316098, 316391, 316683, 316976, //
			317269, 317562, 317855, 318147, 318440, 318733, 319026, 319318, 319611, 319904, 320197, 320489, 320782, 321075, 321368, //
			321660, 321953, 322246, 322539, 322831, 323124, 323417, 323710, 324003, 324295, 324588, 324881, 325174, 325466, 325759, //
			326052, 326345, 326637, 326930, 327223, 327516, 327808, 328101, 328394, 328687, 328979, 329272, 329565, 329858, 330151, //
			330443, 330736, 331029, 331322, 331614, 331907, 332200, 332493, 332785, 333078, 333371, 333664, 333956, 334249, 334542, //
			334835, 335128, 335420, 335713, 336006, 336299, 336591, 336884, 337177, 337470, 337762, 338055, 338348, 338641, 338933, //
			339226, 339519, 339812, 340104, 340397, 340690, 340983, 341276, 341568, 341861, 342154, 342447, 342739, 343032, 343325};

	@Test
	public void test00() {

		int scanInterval = densityCalculator.calculateScanInterval(retentionTimes);
		assertEquals(293, scanInterval);
	}

	@Test
	public void test01() {

		DensityOperation densityOperation = densityCalculator.calculateScanModification(5, 293);
		assertEquals(DensityOperation.INCREASE_ADJUST, densityOperation);
		assertEquals(0, densityOperation.getModifications());
	}

	@Test
	public void test02() {

		int[] retentionTimesAdjusted = densityCalculator.adjustRetentionTimes(retentionTimes, 5);
		assertEquals(540, retentionTimesAdjusted.length);
		assertEquals(185600, retentionTimesAdjusted[0]);
		assertEquals(343600, retentionTimesAdjusted[539]);
		int scanInterval = densityCalculator.calculateScanInterval(retentionTimesAdjusted);
		assertEquals(400, scanInterval);
		DensityOperation densityOperation = densityCalculator.calculateScanModification(5, 400);
		assertEquals(DensityOperation.INCREASE_ADD, densityOperation);
		assertEquals(1, densityOperation.getModifications());
	}
}